package com.kingmed.kmss.bpmn.config;

import org.flowable.engine.impl.db.DbIdGenerator;
import org.flowable.spring.SpringProcessEngineConfiguration;
import org.flowable.spring.boot.EngineConfigurationConfigurer;
import org.flowable.spring.boot.ProcessEngineAutoConfiguration;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@AutoConfigureAfter(ProcessEngineAutoConfiguration.class)
public class FlowableConfiguration {

    @Bean
    public EngineConfigurationConfigurer<SpringProcessEngineConfiguration> customProcessEngineConfigurer() {
        return engineConfiguration -> {
            // do your own thing with the beans and configurations.
            // In theory you can even apply your custom loading of properties here. However,
            // I highly suggest to use the Spring Boot Externalized Configuration

            // 在开发环境中，数据库主键 id 采用数据库生成序列号的方式，可读性好，便于调试
            // 在生产环境中，考虑到分布式存储的情况，数据库主键采用 uuid 方式，不会产生主键冲突
            engineConfiguration.setIdGenerator(new DbIdGenerator());
//			//engineConfiguration.setIdGenerator(new StrongUuidGenerator());
        };
    }

}